import * as Api from '@/api/system/hospital'

const hospital = {
  state: {
  },
  mutations: {
  },
  actions: {
    GetHospitalTree({ commit }, param) {
      return new Promise((resolve, reject) => {
        Api.getHospitalTree(param)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    GetHospitalById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.getHospitalById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    SaveHospital({ commit }, data) {
      return new Promise((resolve, reject) => {
        Api.saveHospital(data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    UpdateHospitalById({ commit }, { id, data }) {
      return new Promise((resolve, reject) => {
        Api.updateHospitalById(id, data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    RemoveHospitalById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.removeHospitalById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}

export default hospital
